<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index()
    {
        if(session('username')){
            $this->display();//渲染所对应的视图文件
        }else{
        $this->error("您好，请先登录!",U('/Home/Login/index/'));
    }

    }

    public function cost(){
        if(session('username')){
            redirect(U('/Home/Cost/index/'),0,'单价管理');
        }else{
            redirect(U('/Home/Login/index/'),0,'重新登录');
        }
    }
    public function usermsg(){
        if(session('username')){
            redirect(U('/Home/Usermsg/index/'),0,'用户信息');
        }else{
            redirect(U('/Home/Login/index/'),0,'重新登录');
        }
    }
    public function record(){
        if(session('username')){
            redirect(U('/Home/Record/index/'),0,'记录管理');
        }else{
            redirect(U('/Home/Login/index/'),0,'重新登录');
        }
    }
    public function loginout(){
        $_SESSION = array();//把一个空数组赋值给session
        session_destroy();//销毁回话对象
        redirect(U('/Home/Login/index/'), '0', '重新登录');
    }

}